import React from "react";
function FnHello() {
  return (
    <div>
      <h1>FnHello</h1>
    </div>
  );
}

class FnClass extends React.Component {
  constructor(props) {
    super(props);
  }

  //e 如果有传参数事件对象就是最后一个参数，如果没有就在第一个
  f1(e) {
    console.log(e)
    //阻止默认事件
    // e.preventDefault();
    // e.stopPropagation();

    console.log(this, "f1 this ");
  }

  f2 = () => {
    console.log(this, "f2 this ");
  };
  render() {
    return (
      <div>
        <h1>Hello Vite FnClass</h1>
        <h1 onClick={this.f1.bind(this)}>Hello Vite FnClass</h1>
        <h1 onClick={() => this.f1()}>Hello Vite FnClass</h1>
        <h1 onClick={this.f2}>Hello Vite FnClass</h1>
      </div>
    );
  }
}

function App() {
  return (
    <div>
      <FnHello></FnHello>
      <FnClass></FnClass>
    </div>
  );
}

export default App;
